﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HPIT_Library_BLL;

namespace HPIT_Library
{
    public partial class type : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GridView1.DataSource = categoryManger.Select();
                GridView1.DataBind();
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            //var userName = user_name.Value;
            //var num= HPIT_Library_BLL.categoryManger.Insert(userName);
            //if (num>0)
            //{
            //    Label_Scuced.Text = "添加成功！！！";
            //    GridView1.DataSource = categoryManger.Select();
            //    GridView1.DataBind();
            //}
        }

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            var id =Convert.ToInt32( e.CommandArgument);
            var name = e.CommandName;
            if (name== "mydelete")
            {
                var num = HPIT_Library_BLL.categoryManger.Delete(id);
                if (num > 0)
                {
                    GridView1.DataSource = categoryManger.Select();
                    GridView1.DataBind();
                }
                else
                {
                    Response.Write("<script>alert('删除失败')</script>");
                }
            }
        }

        
    }
} 